<?php 
namespace Home\Model;

class AdminModel extends YmModel{

	/**
	 * [get_admin_info 根据所给条件获取用户信息]
	 * @param  [Array array('id'=>X , 'name' => X , 'pwd' => X)]
	 *         优先检测Id键
	 *         接着是 name 和 pwd
	 * @return [type]
	 */
	public function get_admin_info($condition){

		if(!is_array($condition)){

			return array('status' => false ,'msg' => '参数错误');
		}
		$where = "";
		if(isset($condition['id'])){

			$where .= 'id = ' . $condition['id'];
		}
		if(isset($condition['name'])){

			$where .= "name = '{$condition['name']}' ";
		}
		$res = $this->where( $where )->find();
		if(!$res && (ym_password( $condition['pwd'] , $res['salt'] ) == $res['pwd'])){
			return array('status' => false , 'msg' => '用户名密码错误');
		}else{
			if($res['status']){

				return array('status' => true , 'msg' => $res);
			}else{

				return array('status' => false , 'msg' => '用户被禁用');
			}
		}
	}

}

 ?>